<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<shiro:hasPermission name="iceperson:select">
	<div class="content1">
		<div class="header">
			<h1 class="page-title">用户明细信息列表</h1>
			<ul class="breadcrumb">
				<li>用户管理</li>
				<li class="active">用户明细信息列表</li>
			</ul>
		</div>
		<div class="main-content">
			<div class="row">
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">手机号码</div>
							<input class="form-control" type="text" id="phoneNum">
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">类型说明</div>
							<select class="form-control" id="type">
							<option value="">请选择</option>
							  <option value="1">家人</option>
							  <option value="2">朋友</option>
							  <option value="3">同事</option>
							</select>
						</div>
					</div>
				</div>
					<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">状态</div>
							<select class="form-control" id="state">
							<option value="">请选择</option>
							  <option value="1">正常</option>
							  <option value="2">锁定</option>
							  <option value="3">冻结</option>
							  <option value="4">审核中</option>
							  <option value="5">通过 </option>
							  <option value="6">审核不通过</option>
							  <option value="6">删除</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<button type="button" class="btn btn-primary btn-small btn-block"
						id="query">
						<i class="glyphicon glyphicon-search"></i> 查询
					</button>
				</div>
				<div class="col-md-2">
					<shiro:hasPermission name="iceperson:add">
						<button type="button" class="btn btn-info btn-small btn-block"
							onclick="addAndUpdateRow(0)">
							<i class="glyphicon glyphicon-plus"></i> 增加
						</button>
					</shiro:hasPermission>
				</div>
			</div>
			<table id="example" class="table"></table>
		</div>
		<script>
			//表格的初始化
				$(document).ready(function() {
				var table = $('#example').initTable({
					sAjaxSource:"iceperson/initTable.htm",
					aoColumns: [
						  { 
							    "data": "phoneNum",
							    "sTitle":"紧急联系人电话",
							    'sClass':"text-center"
						  },
				          { 
				                "data": "type",
				                "sTitle":"紧急联系人类型",
				                'sClass':"text-center",
				                "mRender": function(data, type, full) { 
				                	if(data == 1){
										return "<font color='red'>家人</font>";
									}else if(data == 2){
										return "<font color='red'>朋友</font>";
									}else if(data == 3){
										return "<font color='red'>同事</font>";
									}else{
										return "<font color='red'>未知</font>"
									}
				                } 
				           },
				            { 
							    "data": "trueName",
							    "sTitle":"真实姓名",
							    'sClass':"text-center"
						  	},
				            { 
				                "data": "state",
				                "sTitle":"紧急联系人状态",
				                'sClass':"text-center",
				                "mRender": function(data, type, full) { 
				                	if(data == 1){
										return "<font color='red'>正常</font>";
									}else if(data == 2){
										return "<font color='red'>锁定</font>";
									}else if(data == 3){
										return "<font color='red'>冻结</font>";
									}else if(data == 4){
										return "<font color='red'>审核中</font>";
									}else if(data == 5){
										return "<font color='red'>通过</font>";
									}else if(data == 6){
										return "<font color='red'>审核不通过</font>";
									}else if(data == 7){
										return "<font color='red'>删除</font>";
									}else{
										return "<font color='red'>未知</font>";
									}
				                } 
				            },
				            { 
				              "data": "createTime",
				              "sTitle":"创建时间",
				              'sClass':"text-center"
				            },
				            { 
					              "data": "remark",
					              "sTitle":"备注",
					              'sClass':"text-center"
					         },
			         ],
					 fnServerParams: function (aoData) {  //查询条件
		             	aoData.push({ "name": "phoneNum", "value": $("#phoneNum").val() } );
		             	aoData.push({ "name": "type", "value": $("#type").val() } );
		             	aoData.push({ "name": "state", "value": $("#state").val() } );
		             },
				});
				
				 $('#query').click(function(){
					$('#example').dataTable().fnDraw();
				});
			
			});
			//删除受影响的行数
			function deleteRow(id){
				console.log(id);
				$('#myModal').deleteRow('iceperson/del.htm?id='+id);
			}
			//增加或者修改受影响的行数
			function addAndUpdateRow(id){
				console.info(id);
				$('#insertAndUpdate').addAndUpdateRow("iceperson/addAndUpdateHome.htm?id="+id);
			}
			</script>
		<!---dialog选项-->
		<div>
			<jsp:include page="/WEB-INF/views/common/delete_dialog.jsp" />
			<jsp:include page="/WEB-INF/views/common/addupdate_dialog.jsp" />

			<div class="modal fade" id="insertAndUpdate" tabindex="-1"
				role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			</div>
		</div>
	</div>
</shiro:hasPermission>